package com.qdlc.p2p.biz.protocol;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.qdlc.p2p.common.exception.BorrowException;
import com.qdlc.p2p.common.util.BeanUtil;
import com.qdlc.p2p.dal.dao.OperatorDao;
import com.qdlc.p2p.dal.dto.Operator;

/**
 * 平台下载协议实现类
 * 
 * @author qj
 * @version 2.0
 * @since 2014-05-23
 */
@Service
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class WebProtocol extends AbstractProtocolBean {

	protected OperatorDao operatorDao;

	@Override
	public void prepare() {
		operatorDao = (OperatorDao) BeanUtil.getBean("operatorDao");
	}

	@Override
	public void validDownload() {
		// 先调用父类基础校验
		super.validDownload();
		Operator oper = operatorDao.find(userId);
		if (oper == null) {
			throw new BorrowException("操作异常！");
		}
	}

}
